<template>
	<view>
		<!-- 列表：公建部分+房屋 -->
		<TopNavCustom :title="zone"></TopNavCustom>
		<view class="container">
			<view class="card">
				<u-cell-group v-for="(node, index) in nodeList" :key="index">
					<u-cell size="large" :iconStyle="iconStyle" :title="node.partName" :icon="node._src"
						@click="goto(node)" isLink>
					</u-cell>
				</u-cell-group>
			</view>
			<view class="card">
				<u-cell-group v-for="(node, index) in houseList" :key="index">
					<u-cell size="large" :iconStyle="iconStyle" :title="node.partName" @click="goto(node)" isLink
						icon="/static/selected_icons/selected-5.png">
					</u-cell>
				</u-cell-group>
			</view>
		</view>
	</view>

</template>

<script>
	import _public from '@/common/public.js'
	import _utils from "@/common/_utils.js";
	import _constant from "@/common/constant.js"
	export default {
		onLoad(params) {
			this.zone = params.title
			this.getNode()
		},
		data() {
			return {
				nodeList: [],
				houseList: [],
				zone: '',
				iconStyle: {
					width: '40rpx',
					height: '40rpx'
				},
				_url: ''
			};
		},
		methods: {
			async getNode() {
				let id = await _constant.getConstentPartId('公建芯造')
				const data = await _public.getSelectNode(id)
				if (data.length != 0) {
					this.nodeList = _utils.backNodeArray(data);
				}
				this.houseList = await _public.getHouseNodeColumns()
			},
			goto(node) {
				let _node = node
				if (node.partLevel == 2) {
					_node.estateId = uni.getStorageSync('estateId')
					_node.type = 'building'
				} else {
					_node.type = 'house'
				}
				_node.questionType = this.zone
				let item = encodeURIComponent(JSON.stringify(_node))
				uni.navigateTo({
					url: '/pages/idata/question/question_list_sort/question_list_sort?item=' + item
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 20rpx 30rpx 0 30rpx;

		.image {
			width: 690rpx;
			height: 320rpx;
			margin-bottom: 20rpx;
		}

		.card {
			border: 1rpx solid #EFEFEF;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin-bottom: 40rpx;
		}
	}
</style>
